import { Card, Comment, List,Avatar } from "antd"
import { UserOutlined } from '@ant-design/icons'
import Fromnow from '../compoment/fromnow'
import {Link} from 'react-router-dom'

export default function Commentitem(props){
    let {data=[],loading}=props
    data.reverse();
    return <Card title={'评论列表'} type={'inner'} loading={loading}> 
    <List dataSource={data}
    renderItem={(itemData)=>{
        let {author,content,create_at}=itemData
        return <Comment
        author={<Link to={`/user/${author.loginname}`}>{author.loginname}</Link>   }
        avatar={
            <Avatar icon={<UserOutlined />} 
            src={author.avatar_url} 
            title={author.loginname}/>
        }
        content={<div dangerouslySetInnerHTML={{
            __html:content
        }}></div>}
            datetime={ <tiem> 发表于：{ <Fromnow  data={create_at}  />}</tiem>}
        />
    }}
   pagination={{simple:true}}
    />
   
 
    </Card>
} 